#include <iostream>
using namespace std;

int main() {
    int n; //文章数量
    int m; //标签数
    int k; //标签
    int arr[1001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> m;
        for (int j = 0; j < m; j++) {
            cin >> k;
            arr[k]++;
        }
    }
    int t = 1;
    int max = arr[1];
    for (int i = 2; i <= 1000; i++) {
        if (max < arr[i]) {
            max = arr[i];
            t = i;
        }
    }
    cout << max << " " << t;
    return 0;
}